<template>
  <el-form label-width="130px">
    <el-form-item label="版权名">
      <el-col :span="5">
        <el-input v-model="copyrightin.copyrightName"/>
      </el-col>
    </el-form-item>
    <el-form-item label="公司名">
      <el-col :span="5">
        <el-input v-model="copyrightin.companyName"/>
      </el-col>
    </el-form-item>
    <!-- TODO 分类 -->
    <!-- TODO 版权 -->
    <!-- TODO 批次 -->
    <!-- TODO 书单 -->
    <el-form-item label="合作状态">
      <el-select v-model="copyrightin.status" clearable placeholder="请选择">
        <el-option :value="1" label="生效"/>
        <el-option :value="0" label="失效"/>
      </el-select>
    </el-form-item>
    <el-form-item label="备注名">
      <el-col :span="5">
        <el-input v-model="copyrightin.remarkName"/>
      </el-col>
    </el-form-item>
    <el-form-item label="版权简介">
      <el-input v-model="copyrightin.introduction" :rows="10" type="textarea"/>
    </el-form-item>
    <!-- TODO 书封 -->
    <el-form-item>
      <el-button :disabled="saveBtnDisabled" type="primary" @click="updateCopyrightin()">保存</el-button>
    </el-form-item>
  </el-form>
</template>

<script>
  import copyrightin from '@/api/copyrightin/copyrightin.js'
  import book from "@/api/cms/book";
    export default {
      data() {
        return {
          copyrightin: {
            id: 0
          },
          // saveBtnDisabled: false
        }
      },
      created() {
        this.init()
      },
      methods:{
        init() {
          if (this.$route.params && this.$route.params.id) {
            const id = this.$route.params.id
            this.view(id)
          }
        },
        view(id) {
          // 根据id进行数据查询,回显数据
          copyrightin.view(id)
            .then(response => {
              this.copyrightin = response.data.copyright
            })
        },
        updateCopyrightin(){
          this.saveBtnDisabled=true
          copyrightin.updateCopyrightin(this.copyrightin)
          .then(response =>{
            this.$message({
              type:'success',
              message:'修改成功！'
            })
            this.$router.push('/copyrightin/copyrightin/list')
          })
        }
      }
    }
</script>

<style scoped>

</style>
